home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / compact.arr < prev    next >
Internet Message Format  |  1991-04-12  |  11KB

  1. From comp.sys.handhelds Fri Feb  8 12:58:58 1991
  2. Path: mentor.cc.purdue.edu!noose.ecn.purdue.edu!samsung!sol.ctr.columbia.edu!spool.mu.edu!sdd.hp.com!hplabs!hplabsb!seroussi
  3. From: seroussi@hplabsb.HP.COM (Gadiel Seroussi)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: HP48 compact arrays
  6. Message-ID: <5966@hplabsb.HP.COM>
  7. Date: 7 Feb 91 19:17:48 GMT
  8. Organization: Hewlett Packard Laboratories, Palo Alto
  9. Lines: 212
  10.  
  11. The binary directory (in ASC-> format) appended at the end of this message
  12. uses HP48 linked arrays to implement "compact arrays" of positive integers. 
  13. These arrays allow you to store large tables of positive binary integers using 
  14. significantly less storage than would be required with either real arrays or 
  15. lists of binaries, with an access time comparable to that of real arrays (much 
  16. faster than lists of binaries).
  17. A compact array shows on the stack as "Linked Array", and cannot be edited
  18. directly (conversion routines are provided).
  19. The internal structure of a compact array is as follows:
  20. <02a0a> - header (5 nib)
  21. <size>  - size of object excluding header (5 nib)
  22. <isize> - size of array elements, in nibbles (5 nib)
  23. <n>     - number of elements (5 nib)
  24. <element 1> <element 2> ..... <element n>  (<isize> nibbles each).
  25.  
  26. Other headers could have been choosen but "linked array" was unused enough to
  27. justify the choice (and choices like "code" or "string" would be confusing).
  28.  
  29. The following variables are included:
  30.  
  31. IGETB: retrieve an element of the array, as a binary number.
  32.  
  33.     2: A (compact array)
  34.     1: k (Real)          ----> 1: A(k)  (binary)
  35.  
  36. IGET: retrieve an element of the array, as a real number.
  37.  
  38.     2: A (compact array)
  39.     1: k (Real)          ----> 1: A(k)  (Real).
  40.  
  41. If k <= 0, the number of elements of the array is returned. Subscript range
  42. is checked.
  43.  
  44. IPUT: store a value in the array.
  45.  
  46.     3: A (compact array)
  47.     2: k (Real)
  48.     1: x (Real or binary)  ----> 1: A (compact array, with A(k)=x).
  49.  
  50. Subscript range is checked, k <= 0 is not allowed. The value x is truncated
  51. to the size of the array elements.
  52.  
  53. ICON: generate a compact array with constant elements.
  54.  
  55.     3: n (Real)
  56.     2: isize (Real)
  57.     1: c (Real or binary)  ----> 1: A (compact array).
  58.  
  59. A has n elements, isize nibbles each, all set to the value c. While it is 
  60. legal to set isize > 16, the access routines will only handle up to 16 nibble 
  61. values.
  62.  
  63. ISIZE: find out the value of <isize>.
  64.  
  65.     1: A (compact array)   ----> 1: isize (Real)
  66.  
  67. ITOA: Convert compact array to real array.
  68.  
  69.     1: A (compact array)   ----> 1: RA (Array of Real).
  70.  
  71. ITOB: Convert compact array to list of binaries.
  72.  
  73.     1: A (compact array)   ----> 1: BL (List of Binary).
  74.  
  75. ATOI: Convert real array to compact array.
  76.  
  77.     2: RA (Array of Real)  
  78.     1: isize (real)        ----> 1: A (compact array)
  79.  
  80. BTOI: Convert list of binaries to compact array.
  81.  
  82.     2: BL (List of Binary)
  83.     1: isize (real)        ----> 1: A (compact array)
  84.  
  85. For both ATOI and BTOI, if isize == 0, the least number of nibbles will be 
  86. used that can accomodate the largest value in RA or BL (resp.).
  87.  
  88. BMAX: Find the largest value in a list of binaries (aux. function).
  89.  
  90. p.small: an example of a compact array. A list of the first 1000 prime numbers.
  91.     It takes 2010 bytes of storage, compared to 8012.5 bytes for a real
  92.     array, or around 7000 bytes for a "well packed" list of binaries
  93.     (which ITOB will NOT produce).
  94.  
  95. Other remarks:
  96. 1. The conversion routines are written in user language. Since I consider
  97.    them "one-time" events, no special effort was made to make them faster.
  98. 2. All access routines are affected by the current setting of the binary
  99.    word size (set word size >= isize for things to work properly).
  100.  
  101. This package was developed for a Version D ROM. It may or may not work on
  102. yours. It may or may not destroy your data and/or your calculator.
  103. Use it at your own risk. No warranties of any kind.
  104.  
  105. Enjoy,
  106.  
  107. Gadiel Seroussi
  108. HP Labs (but no relation to Corvallis)
  109.  
  110. -----------------------------------------------------------------------------
  111. Downloadable directory. Download in ASCII mode, use ASC-> to create
  112. a directory object, save it under whatever name you like.
  113.  
  114. %%HP: T(3)A(R)F(.);
  115. "69A20FF7F8910000007007E237D616C6C670A0A20FAF00400008E30020003000
  116. 50007000B000D000110031007100D100F10052009200B200F2005300B300D300
  117. 340074009400F40035009500160056007600B600D6001700F70038009800B800
  118. 59007900D9003A007A00DA003B005B00FB001C005C007C003D00FD003E005E00
  119. 9E00FE001F00BF0010107010D010F01051109110B1105210331073109310D310
  120. B4101510B510D51016107610F6105710B710F7105810D810191099103A105A10
  121. FA101B107B10BB101C109C10DC10FC103D10FD107E10BE103F107F10DF109020
  122. B020D1203220D22033209320B3201420B420152075209520F52056209620B620
  123. 7720182038207820D820392059201A205A20BA203B20DB205C20FC207D20DD20
  124. 3E207E20FE205F209F20103050303130D1309230B23053307330B330D3307430
  125. 55309530B530F530D630173037307730B830F83079301A309A30DA303B309B30
  126. 7C30BC301D307D30FD305E301F305F30BF30DF3070409040F0409140B1405240
  127. 7240D240F340344054409440F4405540D54036409640F7401840B8403940D940
  128. 3A409A401B40DB401C407C40DC40FC405D401E40BE40DF40FF4030509050B050
  129. 115051507150B15072509250F25015507550D550565077501850F85039505950
  130. 9950F9507A50BA50DA503B50FB509C50BC50FC501D505D50BD507E503F50BF50
  131. 7060D06011607160F1603260B260F260D360146074609460D46035605560B560
  132. 56609760F76038605860D9601A603A60DA609B60BB605C60DC603D609D60FD60
  133. 1F607F60BF60DF6090703170F170727073705470B470F4701570557075701670
  134. D67037709770B870D870D970F9705B70BB703C709C70DC70FC703D70BD701E70
  135. BE70DE707F705080F080518012803280728092803380F3801480158035809580
  136. D580F580968017803880B980F9805A80DA80DB80FB803C80BC80BD80DD801E80
  137. 9E80FE805F809F8050907090D19032905290B290F290539034909490D490F490
  138. 55909590F590B6901790779058909890F890B9903A909A90DA907C909D903E90
  139. BE90FE905F907F90DF9031A0F1A012A013A093A0D3A094A075A016A036A076A0
  140. F6A057A0B7A0F7A018A058A0B8A039A079A099A0F9A09AA0BAA05BA0DBA01CA0
  141. FCA09DA05EA07EA0DEA01FA03FA030B011B051B0B1B032B092B0D2B0F3B074B0
  142. 15B075B0D5B056B0F6B0B7B098B0D8B039B099B0B9B07BB09BB03CB0BCB0FCB0
  143. DDB01EB09EB05FB0BFB070C0B0C011C052C0F2C013C014C0B5C0F5C016C0D6C0
  144. 37C077C038C098C019C059C0D9C03BC05BC09BC0BBC07CC03EC05EC0BEC01FC0
  145. 7FC0BFC010D030D0F0D031D0F1D012D0B2D0D2D0D3D0F3D0F4D055D096D097D0
  146. 18D058D078D0B8D0D8D03AD0BAD07BD0DBD07CD09CD0DCD03DD05DD0BDD05ED0
  147. 7ED03FD0DFD0FFD090E071E0D1E012E072E0F2E053E0B3E0B4E075E095E0D5E0
  148. B6E017E057E0D7E078E0F8E059E0B9E01BE07BE09BE03CE01DE05DE0BDE0DEE0
  149. FEE09FE070F0B0F0D0F071F052F092F013F034F074F0D4F0F4F035F095F0B5F0
  150. 76F0B6F0F7F059F01AF03AF07AF0DAF03BF05BF0BBF01DF03DF09DF09EF0FEF0
  151. BFF0DFF03001F001F10112015201B2019301D301F3011501960137019701B701
  152. 5801780119013901D9013A015A01FA011B01BB011C019C017E011F013F01DF01
  153. 5011B01151117211D2119311541174119511F51136119611F61118113811D811
  154. B9111A115A117A11BA113C115C111D117D117E11FE115F11BF11D021D121F121
  155. 32219221B22113217321142174213521F521172137219721D721F8217921FA21
  156. 3B215B219B21FB211C21DC211D21FD21DF217031D03191317231D23173313431
  157. 54319431F4317531D53176319631D631B73118317831B83119313931D931F931
  158. FA31BB313C315D319D31FD31BE31DE313F319F31FF31B1411241F2413341B341
  159. 5441D4419541B641F64117415741D8419941F9411A411B417B41DB41BC415D41
  160. 3E417E415051B05111517151F15152519251B2517351D351145134519451F551
  161. 56517651B651D751F7513851F85119517951B9515B51BB511C515C51DC517D51
  162. 7F5170619061F061316151619161B161526133619361D3615461F46155619661
  163. D661F661576139617961F9619A61FA615B61DB613C61FC613D619D61BD611E61
  164. 5E61BE61DE617F619F619071F0713271727133711471D57136717771B771D871
  165. 5971B971F9715A713B719B71FB719C71BC715D711E719E713F715F71FF717081
  166. 3181D18153817381B38134819481D4815581768117817781D781F7815881F881
  167. B981D9817A81DA813B819B811C817C811D817D819D81FD815E81BE815F81DF81
  168. 5191B19113913391549194911591B591979118913991799199913A919A91BA91
  169. 1B915B917C91FC91BD91DE91DF9130A150A111A171A112A132A1D2A1F2A153A1
  170. F3A1D4A115A196A1B6A1B7A1D7A178A198A139A17AA1BAA1DAA11BA19BA19CA1
  171. FCA15DA17DA13EA13FA1BFA1FFA150B132B152B1F2B113B173B1B3B114B174B1
  172. F4B155B195B156B1B6B137B1F7B138B119B1D9B17AB1FBB15CB11DB17DB19DB1
  173. FEB17FB190C131C191C172C1B2C1D2C133C1D3C154C1B4C1F4C155C137C118C1
  174. B8C1D8C199C13AC15AC15BC17BC19CC11EC13FC19FC190D1B1D112D132D153D1
  175. 93D1F3D114D1B4D135D1D5D136D196D117D157D1B7D1D7D178D198D159D199D1
  176. F9D15AD17AD13BD17BD15CD17DD1BDD11ED15FD19FD110E170E1B0E131E171E1
  177. 52E1B2E1F2E1D3E194E1D4E1F4E1D6E117E198E1F8E159E11AE1DAE1BBE11CE1
  178. 5CE17CE1BCE1DDE13EE1FEE16CF004024D4148540D9D20E1632B7FC1E4A20510
  179. 0000000000000000001C432D6E2010E6D6E2030D61687E16329C2A2D6E2010E6
  180. 301323CE2278BF1D6E2030D61687D5CE1AFE22D9D2045632D6E2030D61687976
  181. 32DCC02B21305BF228DBF15DF22C4232D6E2030D61687EF53293632B2130FD00
  182. 0402445F49440D9D20E16321C432D6E201016D6E2010C6E16323CE22D6E20101
  183. 668BC1D13A2D9AE1AFE22D9D20D6E201016E4A20510002020000000000000933
  184. A1B21305DF22EF5C13392010000000000004605C5C1D6E2010168B9C178BF13C
  185. E22D6E2010C6F88E1AFE22D9D20D6E20101684E204024D41485BB69178BF1F88
  186. E176BA1F49B1339201000000000000610F49B150FA19C2A276BA1D6BB1B21305
  187. BF22D6E2010C65DF22E4A2051000000000000000000084E20409434F4E49C2A2
  188. E0CF10A132D6E201096D6E201096D6E20101692CF16C7D184E204094055545C4
  189. 232DBBF15C5C1EF53293632B2130BD100401445F49440D9D20E16321C432D6E2
  190. 01016D6E2010C6E16323CE22D6E2010168B9C1B7FC19C2A2D9AE1D6E20101668
  191. BC13F2A2D9AE1908E1AFE22D9D20D6E201016E4A205100020200000000000009
  192. 33A1B21305DF22EF5C1DBBF178BF13392010000000000004605C5C13CE22D6E2
  193. 010C6F88E1AFE22D9D20D6E201016E9FB178BF1F88E176BA1F49B13392010000
  194. 00000000610F49B150FA19C2A276BA1D6BB1B21305BF22D6E2010C65DF22E4A2
  195. 051000000000000000000084E20409434F4E49C2A2E0CF10A132D6E201096D6E
  196. 201096D6E20101692CF16C7D184E204094055545C4232DBBF15C5C1EF5329363
  197. 2B21305E100409445F42440D9D20E163278BF14B2A284E2040947454451C432D
  198. 6E2020C616D6E2010E6E16329C2A2D6E2010E60A132D6E201096D6E2020C616D
  199. 6E20109684E20509474544524C4232D6E2010E6387C1EF53293632B21300B000
  200. 409445F41440D9D20E163278BF14B2A284E2040947454451C432D6E2020C616D
  201. 6E2010E6E16329C2A2D6E2010E60A132D6E201096D6E2020C616D6E20109684E
  202. 204094745445C423247A20D6E2010E6B2130900D1EF53293632B21308B000509
  203. 43594A55450D9D20E163278BF19D1A1DBBF18DBF1ED2A2EEDA13392010000000
  204. 0000002090DA1DBBF14B2A284E20409474544550FA193632B213087000409434
  205. F4E440D9D20E1632D9D200FE811192011100B969111920B1100D9D20B2130B21
  206. 303F2A20DCF13CE2278BF1F88E1AFE22D9D208DBF19C2A2B21305DF227F4912A
  207. BF19B191CCD20CC0008FD5F301001098F146601028FB9760119818F2E109818F
  208. 248FEB9301321302034A0A2014416411914416411814416411A1441008F2D760
  209. 8FD8F35118818F29134146D5CE80D016911AD78AB411501136C9134CF6CEF8F2
  210. D7601101C4141CF142164808C93632B213096100409405554540D9D20E1632D9
  211. D200FE8111920B1F50D9D20B21301192011F50B9691B2130E0CF1CB2A1E0CF1A
  212. EC81E0CF1CCD20FC0008FD8F351018F2D7608F146601001438FB976013016414
  213. 2164146818F8EEA103CE80D0E6169110AF8AF0B74100CD4E4D08AA61808A040C
  214. 0C5819F26AEF11B8B6B2136C213411115018F2D760208F73560142164808CD21
  215. 088F2D7601C9818FB18FB976069CF69816D9D20DBBF1FBD81DBBF1E4A2080000
  216. 302933A1B213093632B2130F6100409474544540D9D20E163284E20509474544
  217. 524BB69193632B21306300050947454452450D9D20E1632FDE81119201F500D9
  218. D20AEC81CCD206D0008F14660100143174E78FB9760130164142164146818F8E
  219. EA101CE80D0E6164110D8AF0B741001428A993164CDD08AA61808A040C0C5819
  220. F26AEF1198B673136C2134AF015211028F2D760208F735608FB97602F1128FD6
  221. 950D21088F2D7601C9818FB18FB97606DBFDBBF169816D9D208DBF1FBD81E4A2
  222. 080000302933A1B2130B213093632B2130C713"
  223.  
  224.